package com.yilin.medical.fragment;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.yilin.medical.R;
import com.yilin.medical.activity.BingLiTaoLunDetailsActivity;
import com.yilin.medical.adapter.WoFaBuBingLiAdapter;
import com.yilin.medical.model.WoFaBuBingLiBean;

/**
 * 内分泌
 * 
 * @author lijianqun
 * 
 */
public class WoFaBuBingLiFragment extends Fragment implements
		OnClickListener, OnItemClickListener {
	private Context context;
	private View mView;

	private ListView mListView;
	private WoFaBuBingLiAdapter adapter;

	private List<WoFaBuBingLiBean> mList;

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		context = activity;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		mView = View.inflate(context, R.layout.fragment_shoucangkecheng, null);
		initView();
		initData();
		registerLintener();
		return mView;
	}

	private void initData() {
		mList = new ArrayList<WoFaBuBingLiBean>();

		for (int i = 0; i < 20; i++) {
			WoFaBuBingLiBean sortModel = new WoFaBuBingLiBean();
			mList.add(sortModel);
		}
		
		adapter = new WoFaBuBingLiAdapter(context, mList);
		mListView.setAdapter(adapter);
	}

	private void initView() {
		mListView = (ListView) mView.findViewById(R.id.country_lvcountry);
	}

	private void registerLintener() {
		mListView.setOnItemClickListener(this);

	}

	@Override
	public void onClick(View v) {
	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id) {
		Intent intent;
		switch (parent.getId()) {
		case R.id.country_lvcountry:
			intent = new Intent(context, BingLiTaoLunDetailsActivity.class);
			startActivity(intent);
			break;
		}
	}

}
